import scrapy


class CarhomeSpider(scrapy.Spider):
    name = "carhome"
    allowed_domains = ["www.autohome.com.cn"]
    start_urls = ["https://www.autohome.com.cn/614/price.html"]

    def parse(self, response):
        # print(response.text)
        name_list = response.xpath('//div[@id="specWrap-2"]//p/a[@class="name"]/text()')
        price_list = response.xpath('//div[@id="specWrap-2"]//dl//dd//div[@class="spec-guidance"]//span/text()')
        # print(price_list)

        for i in range(len(name_list)):
            name = name_list[i].extract()
            price = price_list[i].extract()
            print(name,price)
